#pragma once
#ifndef LOGGING_H
#define LOGGING_H
#include <iostream>
#include <ostream>
#include <fstream>
#include <sstream>

enum LoggingLevels {
	LogEPIC=1,
	LogError,
	LogWarning,
	LogInfo,
	LogDebug
};

class Logging {
public:
	Logging();
	~Logging();
	void Open( const char *filename, LoggingLevels _lvl );
	void Write( std::stringstream &s );
	
	LoggingLevels lvl;
private:
	std::ofstream file;
};
extern Logging _logger;

#define LOG_INIT(F, L) _logger.Open(F, L);

#define LOG_EPIC(x) if( _logger.lvl>=LogEPIC ) { \
		std::stringstream s; \
		s << x; \
		_logger.Write(s); \
	}
#define LOG_ERROR(x) if( _logger.lvl>=LogError ) { \
		std::stringstream s; \
		s << x; \
		_logger.Write(s); \
	}
#define LOG_WARN(x) if( _logger.lvl>=LogWarning ) { \
		std::stringstream s; \
		s << x; \
		_logger.Write(s); \
	}
#define LOG_INFO(x) if( _logger.lvl>=LogInfo ) { \
		std::stringstream s; \
		s << x; \
		_logger.Write(s); \
	}
#define LOG_DEBUG(x) if( _logger.lvl>=LogDebug ) { \
		std::stringstream s; \
		s << x; \
		_logger.Write(s); \
	}

#endif
